package core;

import java.awt.Point;
import java.util.LinkedList;

public class Map {
    private static char[][] map;
    public static Point posPabrik;
    
    public static void createMap(int row, int col, char[][] in) {
        map = new char[row][col];
        map = in;
        //debugPrint();
    }                      
    
    public static char getTile(int x, int y) {
        return map[x][y];
    }
    
    public static int getMapWidth() {
        return map[0].length;
    }
    
    public static int getMapHeight() {
        return map.length;
    }
    
    public static char[][] getMap(){
        return map;
    }
    
    public static String debugPrint() {
        StringBuilder sb = new StringBuilder("");
        for(int i=0;i<map.length;i++) {
            for(int j=0;j<map[i].length;j++) {
                sb.append(map[i][j]).append(" ");
                if (mapContent.isPabrik(i, j)){
                    posPabrik = new Point(i,j);
                }
                if (!mapContent.isRumput(i, j)){
                    Astar.walkability[i][j]=true;
                    GreedyBF.walkability[i][j]=true;
                }
                if (mapContent.isVendor(i, j)&&(!mapContent.isPabrik(i, j))){
                    for(int it=0;it<VendorList.getList().size();it++){
                        //System.out.println(VendorList.getVendor(it).NAME+" -> "+getTile(i,j)+" "+i+","+j);
                        if (VendorList.getVendor(it).NAME.charAt(0)==getTile(i,j)){
                            VendorList.getVendor(it).setPoint(i, j);
                            //System.out.println(VendorList.getVendor(it).NAME+" = "+VendorList.getVendor(it).posVendor.x+","+VendorList.getVendor(it).posVendor.y);
                            //break;
                        }
                    }
                }
            }
            sb.append("\n");
        }
        return sb.toString();
    }
    
    public static void main(String[] args){
        Parser.parse("input5x5.txt");
        Map.debugPrint();
        System.out.println("size "+VendorList.getList().size());
        for(int i=0;i<VendorList.getList().size();i++){
            System.out.println(VendorList.getVendor(i).NAME+" = "+VendorList.getVendor(i).getPoint().x+","+VendorList.getVendor(i).getPoint().y);
        }
        
    }
}
